In [1]:
import tensorflow as tf
In [7]:
# abs
# To get absolute value of a Tensor or placeholder or scalar
x = tf.constant([[-3, 3], [2, -3 - 4j]])
val = tf.abs(x, name = 'abs')
sess = tf.Session()
sess.run(val)
Out[7]:
In [9]:
# accumulate_n
# To get element wise sum of a tensor
x = tf.constant([[2,4], [3,1]])
y = tf.constant([[5,0], [2,3]])
val = tf.accumulate_n([x,y], shape=[2,2], tensor_dtype = tf.int32, name='accumuate_n')
sess.run(val)
# It is not differentiable as it calculates the sum as the inputs are
# provided. To get differentiable output use add_n
Out[9]:
In [10]:
# acos
# To get element wise cos of all elements
# acosh
In [12]:
# add
# To add two tensors
# It supports broadcasting
x = tf.constant([1,2])
y = tf.constant([[1,2], [3,4]])
val = tf.add(x, y, name = 'add')
sess.run(val)
Out[12]:
In [21]:
# add_n
# To do the same operation as add except broadcasting is not allowed
# It takes list as an input
val = tf.add_n([y, y, y])
sess.run(val)
Out[21]:
In [22]:
In [ ]:
# Casting
tensor = tf.